home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -serious- / programming / other / vahunz / vahunz-tschak < prev    next >
Text File  |  1999-09-06  |  32KB  |  1,019 lines

  1. ; $VER: Vahunz-Tschak 1.2 (16.8.98)
  2. ;
  3. ; Copyright 1998,99 Thomas Aglassinger. All rights reserved.
  4. ;
  5. ; A case tool to create a script that runs Vahunz. The user can select a
  6. ; basic mode for vahunzation. The file list is generated automatically
  7. ; and the dignorary can be selected. On request, Vahunz can create the
  8. ; dictionary and the editor is launched immediately after creation.
  9. ;
  10. ; Additionally you can create or update dignoraries with it.
  11.  
  12. ; TODO: make a more clear interface flow by first offering to vahunz
  13. ;       source code or create a dignorary
  14. ; TODO: expose more options when in mode "custom"
  15. ; TODO: when JDK's index-?.html does not exist, offer to retry with a
  16. ;       new name instead of terminating whole script
  17.  
  18. ; Specify minimum installer version
  19.  
  20. (debug "set version")
  21. (set #minimum-installer-version 43)
  22. (set #minimum-installer-revision 3)
  23. (set #minimum-installer-id
  24.    (+ #minimum-installer-revision
  25.        (* #minimum-installer-version 65536)
  26.    )
  27. )
  28. (debug "  minimum-installer-id = " #minimum-installer-id)
  29. (debug "  current-installer-id = " @installer-version)
  30.  
  31. ; Figure full path name of vahunz executable
  32. (debug "expand vahunz path")
  33. (set #expanded-vahunz
  34.    (cat "\"" (expandpath "vahunz") "\"")
  35. )
  36. (debug "  " #expanded-vahunz)
  37.  
  38. ; Filename for the CLI script to be created. Later on the source
  39. ; directory is inserted at the beginning of this name.
  40. (set #file-vahunz-it "Vahunz it!")
  41.  
  42. ; Texts for messages, prompts and help
  43.  
  44. (
  45. (set #message-welcome
  46. (cat "Welcome to Vahunz-Tschak, the script generator for Vahunz.\n"
  47. ))
  48.  
  49. (set #message-wrong-installer
  50. (cat "You have an old version of the program 'Installer' on your Amiga!\n\n"
  51.      "The installation procedure needs at least Installer "
  52.      #minimum-installer-version "." #minimum-installer-revision ".\n\n"
  53.      "Please obtain a newer version!\n\n"
  54.      "(Check Aminet or "
  55.      "the WWW site of the current owner of the rights for Amiga.)"
  56. ))
  57.  
  58. (set #message-wrong-list
  59. (cat "This script requires the standard 'c:list' command to be installed.\n\n"
  60.      "It seems you are using some incompatible replacement."
  61. ))
  62.  
  63. (set #message-overview
  64. (cat "Vahunz-Tschak is a frontend for Vahunz to spare you fiddling with "
  65.      "command line options.\n\n"
  66.      "It asks you some questions concerning "
  67.      "the location of your source code and options for vahunz. After that "
  68.      "it creates a CLI-script \"" #file-vahunz-it "\" you can invoke at "
  69.      "any time to perform the vahunzation.\n\n"
  70.      "If you are unsure about the meaning of a question, click the \"Help\" "
  71.      "button or take a look at the manual."
  72. ))
  73.  
  74. ; Choices for basic vahunz mode
  75. (set #choice-vahunz-standard "Standard")
  76. (set #choice-vahunz-exchange "Exchange")
  77. (set #choice-vahunz-rename   "The Great Renaming")
  78. (set #choice-vahunz-custom   "Custom")
  79. (set #choice-create-c        "Create C/C++ dignorary")
  80. (set #choice-create-java     "Create Java dignorary")
  81.               
  82.               
  83.  
  84. (set #prompt-vahunz-mode "Select the kind of vahunzation you want to perform:")
  85. (set #help-vahunz-mode
  86. (cat "This specifies what vahunz should do with your sources.\n\n"
  87.      #choice-vahunz-standard " - Perform a standard vahunzation mostly using "
  88.      "default options. This gives you a reasonably unreadable source code "
  89.      "without comments and indention you can use to distribute to normal "
  90.      "users who only want to compile it and nothing else."
  91.      "\n\n"
  92.      #choice-vahunz-exchange " - Works like \"" #choice-vahunz-standard "\", "
  93.      "but preserves line numbers in the vahunzed source. This gives accurate "
  94.      "line numbers referring to your original source if users report source "
  95.      "code related errors like problems during compilation."
  96.      "\n\n"
  97.      #choice-vahunz-rename " - Does not remove any data from your original "
  98.      "code but only creates a dictionary prepared for "
  99.      "\"The Great Renaming\"."
  100.      "\n\n"
  101.      #choice-vahunz-custom " - Asks you all options to be specified manually. "
  102.      "This is useful for maximum control over the vahunzation."
  103.      "\n\n"
  104.      #choice-create-c " - Lets you specify your include directory and creates "
  105.      "a dignorary from it."
  106.      "\n\n"
  107.      #choice-create-java " - Lets you specify your Javadoc directory and "
  108.      "creates a dignorary from it."
  109. ))
  110.  
  111. ; Choices for source type
  112. (set #choice-source-c    "C/C++")
  113. (set #choice-source-java "Java")
  114.  
  115. (set #prompt-source-type
  116.      "Select the type of source codes that should be vahunzed:"
  117. )
  118. (set #help-source-type
  119. (cat "The source type decides for which file pattern the source directory is "
  120.      "scanned."
  121. ))
  122.  
  123. (set #prompt-source-directory
  124. (cat "Select source directory to scan for source codes and where the support "
  125.      "files for vahunz will be stored:"
  126. ))
  127. (set #help-source-directory
  128. (cat "The directory you selected and all its sub-directories are scanned for "
  129.      "source codes to be vahunzed.\n\n"
  130.      "Support files like \"vahunz.files\" and the dictionaries are also "
  131.      "stored there. This includes the \"" #file-vahunz-it "\" CLI-script "
  132.      "created by Vahunz-Tschak at the end."
  133. ))
  134. (set #prompt-source-pattern
  135.      "Enter pattern for source file to be vahunzed:"
  136. )
  137. (set #help-source-pattern
  138. (cat "Here you can specify a AmigaDOS pattern the files in the source "
  139.      "directory have to match to be considered for vahunzation."
  140.      "\n\n"
  141.      "For example, #?.(c|h) specifies all C sources and headers."
  142.      "\n\n"
  143.      "All sub-directories within the source directory are also scanned."
  144. ))
  145.  
  146. (set #prompt-dignorary
  147.      "Select default dignorary to be used by vahunz:"
  148. )
  149. (set #help-dignorary
  150. (cat "The dignorary is a special dictionary containing names you know that "
  151.      "you don't want them to vahunz already beforehand. It usually "
  152.      "contains names of functions and constants of standard and system "
  153.      "libraries.\n\n"
  154.      "If you do not want to use a dignorary, choose \"empty.ignore\"."
  155. ))
  156.  
  157. (set #prompt-custom-switches "Select the switches you want to enable")
  158. (set #help-custom-switches
  159. (cat "Here you can enable switches that will influence the output Vahunz "
  160.      "creates."
  161. ))
  162.  
  163. (set #message-create-vahunz-files-1
  164.      "Creating \""
  165. )
  166. (set #message-create-vahunz-files-2
  167.      "\" using the following command:"
  168. )
  169. (set #help-create-vahunz-files
  170. (cat "This command creates the \"vahunz.files\" containing all source files "
  171.      "vahunz should take into account."
  172. ))
  173.  
  174. (set #message-create-vahunz-ignore-1
  175.      "Creating \""
  176. )
  177. (set #message-create-vahunz-ignore-2
  178.      "\" using the following command:"
  179. )
  180. (set #help-create-vahunz-ignore
  181. (cat "This command creates dignorary \"vahunz.ignore\" containig all names "
  182.      "to be ignored."
  183. ))
  184.  
  185. (set #prompt-create-vahunz-it
  186. (cat "Writing \"" #file-vahunz-it "\""
  187. ))
  188. (set #help-vahunz-it
  189. (cat "\"" #file-vahunz-it "\" is the CLI-script created by Vahunz-Tschak "
  190.      "that actually performs the vahunzation. "
  191.      "\n\n"
  192.      "You can call it whenever you updated your original source code and "
  193.      "want to create a new vahunzed version."
  194. ))
  195.  
  196. (set #prompt-target-directory
  197. (cat "Select target directory where the vahunzed source code should be "
  198.      "stored:"
  199. ))
  200. (set #help-target-directory
  201. (cat "To preserve your original source code, the vahunzed one is written "
  202.      "to a different directory, but with the same filenames."
  203.      "\n\n"
  204.      "This usually allows you to use the same scripts and Makefile for "
  205.      "compilation as for the original."
  206. ))
  207.  
  208. (set #work-create-script  "Creating script")
  209. (set #work-copy-dignorary "Copying dignorary from")
  210.  
  211. (set #prompt-launch-vahunz
  212. (cat "The script has been created. To also create the dictionary it has to be "
  213.      "executed.\n\n"
  214.      "Do you want me to start the script now?"
  215. ))
  216. (set #help-launch-vahunz
  217. (cat "You can execute the script now to make vahunz extract all names of your "
  218.      "source code and create the dictionary.\n\n"
  219.      "If you do not want to do that right now, you can skip this part and "
  220.      "execute the script later from Workbench or CLI."
  221. ))
  222.  
  223. (set #status-vahunzing
  224. (cat "Vahunzing...\n\n"
  225.      "(This can take a while)"
  226. ))
  227.  
  228. (set #prompt-editor
  229. (cat "The dictionary has been created.\n\n"
  230.      "It can now be loaded into your editor. There you can and modify the "
  231.      "lines  want to vahunz/rename."
  232. ))
  233. (set #help-editor
  234. (cat "Your editor according to the environment variable EDITOR will be "
  235.      "started and load the dictionary.\n\n"
  236.      "Mark words you want to vahunz with plus (+) and those you want to "
  237.      "ignore with minus (-).\n\n"
  238.      "To rename a name, leave the first character blank and specify the "
  239.      "new name after an equal sign (=), for example:\n\n"
  240.      "\" rdcfg=read_settings\""
  241. ))
  242.  
  243. (set #message-exit
  244. (cat "A CLI-script has been created in \"%s\"."
  245.      "\n\n"
  246.      "You can perform the vahunzation by executing this script from CLI "
  247.      "or by double-clicking it from the Workbench."
  248.      "\n\n"
  249.      "As the script automatically goes to the source directory and also "
  250.      "restores the current directory upon exit, you can safely invoke it "
  251.      "from other scripts, Makefiles or similar."
  252.      "\n\n"
  253.      "Happy Vahunzing!"
  254. ))
  255. )
  256.  
  257. (set #prompt-include-directory "Select C/C++ include directory")
  258. (set #help-include-directory
  259. (cat "The include directory contains all your header files with names you want "
  260.      "to ignore when vahunzing source codes."
  261. ))
  262.  
  263. (set #working-list-include-files  "Creating include file list")
  264. (set #working-scan-include-files  "Scanning include files")
  265. (set #working-translate-dignorary "Replacing blanks by hyphens")
  266. (set #working-cleanup-dignorary   "Cleaning up dignorary")
  267.  
  268. (set #prompt-javadoc-directory "Select include directory")
  269. (set #help-javadoc-directory
  270. (cat "The include directory contains your system header files."
  271.      "\n\n"
  272.      "They usually contain variables, prototypes and macros you do not "
  273.      "want to vahunz."
  274. ))
  275.  
  276. (set #prompt-javadoc-directory "Select Javadoc directory")
  277. (set #help-javadoc-directory
  278. (cat "The Javadoc directory contains the API documentation in HTML format. All "
  279.      "documents matching the file pattern \"[a-z]-index.html\" in this "
  280.      "directory are scanned for references."
  281.      "\n\n"
  282.      "That means, a file named \"a-index.html\" has to exist in the directory "
  283.      "you select, otherwise it will be rejected."
  284. ))
  285. (set #message-bad-javadoc-directory
  286. (cat "The directory selected does not contain a file named \"index-1.html\". "
  287.      "Therefor this is not considered to be a directory containing API "
  288.      "documentation in JavaDoc format."
  289.      "\n\n"
  290.      "Select a proper directory next time."
  291. ))
  292.  
  293. (set #working-scan-javadoc "Scanning \"%s\"")
  294. (set #working-cleanup-javadoc "Cleaning temporary dignorary using vahunz")
  295.  
  296. (set #prompt-target-dignorary "Specify target dignorary to create")
  297. (set #help-target-dignorary
  298. (cat "Specify directory and filename of the target directory."
  299.      "\n\n"
  300.      "Preferably, it should be stored in the standard dignorary directory "
  301.      "and should have the suffix \".ignore\"."
  302. ))
  303.  
  304. (set #message-exit-dignorary
  305. (cat "The new dignorary has been stored in \"%s\"."
  306.      "\n\n"
  307.      "It is ready for your next vahunzation."
  308. ))
  309. ;----------------------------------------------------------------------------
  310. ; Run a command and check for a certain return code
  311. ;----------------------------------------------------------------------------
  312. (procedure P-run #name #expected-result #command
  313. (
  314.    (debug "  name = " #name)
  315.    (debug "  expt = " #expected-result)
  316.    (debug "  comd = " #command)
  317.  
  318.    (set #real-result (run #command))
  319.    (if (<> #expected-result #real-result)
  320.       (
  321.          (abort #name " returned " #real-result " instead of "
  322.                 #expected-result ":\n\n"
  323.                 #command)
  324.       )
  325.    )
  326. ))
  327.  
  328. ;----------------------------------------------------------------------------
  329. ; Execute a script and check for a certain return code
  330. ;----------------------------------------------------------------------------
  331. (procedure P-execute #name #expected-result #command
  332. (
  333.    (debug "  name = " #name)
  334.    (debug "  expt = " #expected-result)
  335.    (debug "  comd = " #command)
  336.  
  337.    (set #real-result (execute #command))
  338.    (if (<> #expected-result #real-result)
  339.       (
  340.          (abort #name " returned " #real-result " instead of "
  341.                 #expected-result ":\n\n"
  342.                 #command)
  343.       )
  344.    )
  345. ))
  346.  
  347. ;----------------------------------------------------------------------------
  348. ; Load certain file into editor
  349. ;----------------------------------------------------------------------------
  350. (procedure P-edit #file #prompt #help
  351. (
  352.    ; Get editor from $EDITOR or use c:Ed
  353.  
  354.    (set #editor (getenv "editor"))
  355.    (if (= "" #editor) ((set #editor "c:Ed")))
  356.  
  357.    (debug "editor = " #editor)
  358.  
  359.    ; Run editor
  360.  
  361.    (set #command-editor (cat #editor " \"" #file "\""))
  362.    (run #command-editor
  363.       (prompt #prompt)
  364.       (help #help)
  365.       (confirm "average")
  366.    )
  367. ))
  368.  
  369. ;----------------------------------------------------------------------------
  370. ; Check requirements
  371. ;----------------------------------------------------------------------------
  372.  
  373. ; Check installer version to piss people off and make them
  374. ; download a new one or dump the whole filetype (He he he).
  375. ; (The script should work with older versions, but how am I
  376. ; supposed to test this?)
  377.  
  378. (procedure P-check-requirements
  379.    (debug "check version")
  380.    (if (< @installer-version #minimum-installer-id)
  381.      (
  382.        (debug "installer too old")
  383.        (abort #message-wrong-installer)
  384.      )
  385.    )
  386.  
  387.    (debug "check list")
  388.    (if (run "list >nil: lformat=%p%n all pat=#?")
  389.      (
  390.        (debug "no/wrong list")
  391.        (abort #message-wrong-list)
  392.      )
  393.  
  394. ))
  395.  
  396. ;----------------------------------------------------------------------------
  397. ; Welcome user
  398. ;----------------------------------------------------------------------------
  399.  
  400. (procedure P-welcome
  401.    (debug "welcome")
  402.    (welcome #message-welcome)
  403.  
  404.    (message #message-overview)
  405. )
  406.  
  407. ;----------------------------------------------------------------------------
  408. ; Ask for basic vahunz mode
  409. ;----------------------------------------------------------------------------
  410.  
  411. (procedure P-ask-vahunz-mode
  412.    (debug "ask vahunz mode")
  413.  
  414.    (set #vahunz-mode
  415.       (askchoice
  416.           (choices
  417.               #choice-vahunz-standard
  418.               #choice-vahunz-exchange
  419.               #choice-vahunz-rename
  420.               #choice-vahunz-custom
  421.               #choice-create-c
  422.               #choice-create-java
  423.           )
  424.           (prompt #prompt-vahunz-mode)
  425.           (help #help-vahunz-mode)
  426.       )
  427.    )
  428.    (debug "vahunz-mode = " #vahunz-mode)
  429.  
  430.    (select #vahunz-mode
  431.  
  432.       ; Standard
  433.       (set #vahunz-options "")
  434.  
  435.       ; Exchange
  436.       (set #vahunz-options "--line --random-seed=1 --store")
  437.  
  438.       ; The Great Renaming
  439.       (set #vahunz-options "--comment --indent --line --no-unused")
  440.  
  441.       ; Custom
  442.       (set #vahunz-options "*custom*")
  443.  
  444.       ; Create C dignorary
  445.       (set #vahunz-options "*create-c*")
  446.  
  447.       ; Create C dignorary
  448.       (set #vahunz-options "*create-java*")
  449.  
  450.    )
  451.    (debug "vahunz-options = " #vahunz-options)
  452. )
  453.  
  454. ;----------------------------------------------------------------------------
  455. ; Ask for source type
  456. ;----------------------------------------------------------------------------
  457.  
  458. (procedure P-ask-source-type
  459.    (debug "ask source type")
  460.  
  461.    (set #source-type
  462.       (askchoice
  463.           (choices
  464.               #choice-source-c
  465.               #choice-source-java
  466.           )
  467.           (prompt #prompt-source-type)
  468.           (help #help-source-type)
  469.       )
  470.    )
  471.    (debug "source-type = " #source-type)
  472. )
  473.  
  474. ;----------------------------------------------------------------------------
  475. ; Ask for source directory
  476. ;----------------------------------------------------------------------------
  477.  
  478. (procedure P-ask-source-directory
  479.    (debug "ask source directory")
  480.  
  481.    (if (= @app-name "debug")
  482.    (
  483.        set #source-directory "prog:SmartReadArgs"
  484.    )
  485.    (
  486.        (set #source-directory
  487.        (askdir
  488.           (prompt #prompt-source-directory)
  489.           (help #help-source-directory)
  490.           (default "Work:")
  491.        ))
  492.    )
  493.    ) ;if
  494.  
  495.    (debug "source directory = " #source-directory)
  496. )
  497.  
  498. ;----------------------------------------------------------------------------
  499. ; Ask for source pattern
  500. ;----------------------------------------------------------------------------
  501.  
  502. (procedure P-ask-source-pattern
  503.    (debug "choose source pattern")
  504.  
  505.    (select #source-type
  506.  
  507.       ; C/C++
  508.       (
  509.          (set #source-pattern "#?.(c|h|c++|cxx|cpp|cc)")
  510.          (set #default-dignorary "amiga.ignore")
  511.       )
  512.  
  513.       ; Java
  514.       (
  515.          (set #source-pattern "#?.(java|jav)")
  516.          (set #default-dignorary "java.ignore")
  517.       )
  518.  
  519.       ; Others (currently disabled)
  520.       (
  521.           (set #source-pattern
  522.           (askstring
  523.              (prompt #prompt-source-pattern)
  524.              (help #help-source-pattern)
  525.              (default "#?.(c|h|c++|cxx|cpp|cc)")
  526.           ))
  527.       )
  528.    )
  529.  
  530.    (debug "source pattern = " #source-pattern)
  531. )
  532.  
  533. ;----------------------------------------------------------------------------
  534. ; Ask for dignorary
  535. ;----------------------------------------------------------------------------
  536.  
  537. (procedure P-ask-dignorary
  538.    (debug "ask dignorary")
  539.  
  540.    (set #dignorary
  541.    (askfile
  542.       (prompt #prompt-dignorary)
  543.       (help #help-dignorary)
  544.       (default (tackon "dignorary" #default-dignorary))
  545.    ))
  546.  
  547.    (debug "dignorary = " #dignorary)
  548. )
  549.  
  550. ;----------------------------------------------------------------------------
  551. ; Ask for target directory
  552. ;----------------------------------------------------------------------------
  553.  
  554. (procedure P-ask-target-directory
  555.    (debug "ask target directory")
  556.  
  557.    (set #target-directory
  558.    (askdir
  559.       (prompt #prompt-target-directory)
  560.       (help #help-target-directory)
  561.       (default "ram:")
  562.    ))
  563.  
  564.    (debug "dignorary = " #target-directory)
  565. )
  566.  
  567. ;----------------------------------------------------------------------------
  568. ; Ask options in case of vahunz mode set to "Custom"
  569. ;----------------------------------------------------------------------------
  570. (procedure P-ask-custom-switches
  571.    (if (= #vahunz-options "*custom*")
  572.       (
  573.          ; Ask for switches
  574.  
  575.          (set #options
  576.          (askoptions
  577.             (prompt #prompt-custom-switches)
  578.             (help #help-custom-switches)
  579.             (default 0)
  580.             (choices
  581.                "Preserve comments (--comment)"
  582.                "Preserve indention (--indent)"
  583.                "Preserve line numbers (--line)"
  584.                "Remove unused names from dictionary (--no-unused)"
  585.                "Store vahunzed names in dictionary (--store)"
  586.                "Suppress warning messages (--no-warning)"
  587.             )
  588.          ))
  589.          (set #vahunz-options "")
  590.          (if (IN #options 0) (set #vahunz-options (cat #vahunz-options " --comment")))
  591.          (if (IN #options 1) (set #vahunz-options (cat #vahunz-options " --indent")))
  592.          (if (IN #options 2) (set #vahunz-options (cat #vahunz-options " --line")))
  593.          (if (IN #options 3) (set #vahunz-options (cat #vahunz-options " --no-unused")))
  594.          (if (IN #options 4) (set #vahunz-options (cat #vahunz-options " --store")))
  595.          (if (IN #options 5) (set #vahunz-options (cat #vahunz-options " --no-warning")))
  596.       )
  597.    )
  598. )
  599.  
  600. ;----------------------------------------------------------------------------
  601. ; Create "vahunz.files"
  602. ;----------------------------------------------------------------------------
  603.  
  604. (procedure P-create-vahunz.files
  605.    (set #vahunz-files (tackon #source-directory "vahunz.files"))
  606.    (set #file-command-list "t:vahunz-tschack-list.tmp")
  607.  
  608.    (working "Creating \"" #vahunz-files "\"")
  609.  
  610.    (set #command-sequence-list
  611.    (cat "cd \"" #source-directory "\"\n"
  612.         "list lformat=%p%n all "
  613.            "pat=\"" #source-pattern "\" "
  614.            ">\"" #vahunz-files "\"\n"
  615.    ))
  616.  
  617.    (debug "command: " #command-sequence-list)
  618.  
  619.    (textfile
  620.       (dest #file-command-list)
  621.       (append #command-sequence-list)
  622.    )
  623.  
  624.    (P-execute "#file-command-list" 0 #file-command-list)
  625.    (delete #file-command-list)
  626.  
  627. )
  628.  
  629. ;----------------------------------------------------------------------------
  630. ; Create "vahunz.ignore"
  631. ;----------------------------------------------------------------------------
  632.  
  633. (procedure P-create-vahunz.ignore
  634.    (set #vahunz-ignore (tackon #source-directory "vahunz.ignore"))
  635.  
  636.    (set #command-copy-dignorary
  637.    (cat "copy quiet clone "
  638.         "from=\"" #dignorary "\" "
  639.         "to=\"" #vahunz-ignore "\""
  640.    ))
  641.  
  642.    (debug "command: " #command-copy-dignorary)
  643.  
  644.    (working #work-copy-dignorary " \"" #vahunz-ignore "\"")
  645.  
  646.    (P-run "#command-copy-dignorary" 0 #command-copy-dignorary)
  647. )
  648.  
  649. ;----------------------------------------------------------------------------
  650. ; Create "Vahunz it!"
  651. ;----------------------------------------------------------------------------
  652.  
  653. (procedure P-create-vahunz-it
  654.    (set #vahunz-it (tackon #source-directory #file-vahunz-it))
  655.    (set #vahunz-it-icon (cat #vahunz-it ".info"))
  656.  
  657.    (working #work-create-script " \"" #vahunz-it "\"")
  658.  
  659.    (set #command-vahunz-it
  660.    (cat "assign vahunz-cd-<$$>: \"\"\n"
  661.         "cd \"" #source-directory "\"\n"
  662.         #expanded-vahunz
  663.             " " #vahunz-options
  664.             " \"--output=" #target-directory "\" "
  665.         "\n"
  666.         "cd vahunz-cd-<$$>:\n"
  667.         "assign vahunz-cd-<$$>: remove\n"
  668.    ))
  669.  
  670.    (debug "vahunz-it contents:\n---\n"
  671.           #command-vahunz-it
  672.           "---")
  673.  
  674.    (textfile
  675.       (prompt #promp-create-vahunz-it)
  676.       (help #help-vahunz-it)
  677.       (dest #vahunz-it)
  678.       (append #command-vahunz-it)
  679.    )
  680.  
  681.    (set #command-copy-icon
  682.    (cat "copy quiet clone "
  683.         "from=tschak/def_vahunz.info "
  684.         "to=\"" #vahunz-it-icon "\""
  685.    ))
  686.  
  687.    (P-run "#command-copy-icon" 0 #command-copy-icon)
  688.  
  689.    ; Set "S" protection bit of "Vahunz it!"
  690.    (set #command-protect-vahunz-it
  691.    (cat "protect \"" #vahunz-it "\" +s"
  692.    ))
  693.  
  694.    (P-run "#command-protect-vahunz-it" 0 #command-protect-vahunz-it)
  695. )
  696.  
  697. ;----------------------------------------------------------------------------
  698. ; Invoke "Vahunz it!"
  699. ;----------------------------------------------------------------------------
  700.  
  701. (procedure P-invoke-vahunz-it
  702.    (set #vahunz-launched
  703.    (askbool
  704.       (prompt #prompt-launch-vahunz)
  705.       (help #help-launch-vahunz)
  706.       (default 1)
  707.    ))
  708.  
  709.    (debug "launch vahunz = " #vahunz-launched)
  710.  
  711.    (if #vahunz-launched
  712.       (
  713.          (working #status-vahunzing)
  714.          (P-run "#vahunz-it" 0 (cat "execute \"" #vahunz-it "\""))
  715.  
  716.          ; We can't use P-execute here because it does not quote the name
  717.       )
  718.    )
  719. )
  720.  
  721. ;----------------------------------------------------------------------------
  722. ; Edit "vahunz.names"
  723. ;----------------------------------------------------------------------------
  724.  
  725. (procedure P-edit-vahunz.names
  726.    (set #vahunz-names (tackon #source-directory "vahunz.names"))
  727.    (if #vahunz-launched (P-edit #vahunz-names #prompt-editor #help-editor))
  728. )
  729.  
  730. ;----------------------------------------------------------------------------
  731. ; Exit message
  732. ;----------------------------------------------------------------------------
  733.  
  734. (procedure P-exit
  735.    (exit
  736.        (#message-exit #vahunz-it)
  737.        (quiet)
  738. ))
  739.  
  740. ;----------------------------------------------------------------------------
  741. ; Ask for include directory
  742. ;----------------------------------------------------------------------------
  743.  
  744. (procedure P-ask-include-directory
  745. (
  746.    (debug "ask include directory")
  747.  
  748.    (set #include-directory
  749.    (askdir
  750.       (prompt #prompt-include-directory)
  751.       (help #help-include-directory)
  752.       (default "include:")
  753.    ))
  754. ))
  755.  
  756. ;----------------------------------------------------------------------------
  757. ; Create include file list
  758. ;----------------------------------------------------------------------------
  759.  
  760. (procedure P-create-include-files
  761. (
  762.    (debug "list include files")
  763.  
  764.    (working #working-list-include-files)
  765.  
  766.    (set #command-list-include
  767.    (cat "list >t:temporary.files lformat=%p%n all pat=#?.h "
  768.         #include-directory
  769.    ))
  770.  
  771.    (P-run "#command-list-include" 0 #command-list-include)
  772. ))
  773.  
  774. ;----------------------------------------------------------------------------
  775. ; Scan include file
  776. ;----------------------------------------------------------------------------
  777.  
  778. (procedure P-scan-include-files
  779. (
  780.    (debug "scan include files")
  781.  
  782.    (working #working-scan-include-files)
  783.  
  784.    (delete "t:temporary.names"  (optional "force"))
  785.    (delete "t:temporary.ignore" (optional "force"))
  786.  
  787.    (set #command-scan-include "vahunz --base-name t:temporary")
  788.  
  789.    (P-run "#command-scan-include" 0 #command-scan-include)
  790. ))
  791.  
  792. ;----------------------------------------------------------------------------
  793. ; Translate and append include dignorary
  794. ;----------------------------------------------------------------------------
  795.  
  796. (procedure P-translate-dignorary
  797. (
  798.    (debug "translate dignorary")
  799.  
  800.    (working #working-translate-dignorary)
  801.  
  802.    (set #command-translate-dignorary
  803.    (cat "tschak/blank-to-hyphen"
  804.         " <t:temporary.names"
  805.         " >>t:temporary.ignore"
  806.    ))
  807.  
  808.    (P-run "#command-translate-dignorary" 0 #command-translate-dignorary)
  809.  
  810.    ; Delete the name list and launch vahunz again to sort the whole mess
  811.    ; and kick out possible duplicates
  812.    (debug "cleanup dignorary")
  813.  
  814.    (working #working-cleanup-dignorary)
  815.    (delete "t:temporary.names" (optional "force"))
  816.  
  817.    (set #command-cleanup-dignorary "vahunz --base-name t:temporary")
  818.    (P-run "#command-cleanup-dignorary" 0 #command-cleanup-dignorary)
  819. ))
  820.  
  821.  
  822.  
  823. ;----------------------------------------------------------------------------
  824. ; Ask for target dignorary name
  825. ;----------------------------------------------------------------------------
  826.  
  827. (procedure P-ask-target-dignorary #name
  828. (
  829.    (debug "ask target dignorary")
  830.  
  831.    (set #target-dignorary
  832.    (askfile
  833.       (prompt #prompt-target-dignorary)
  834.       (help #help-target-dignorary)
  835.       (default (tackon "dignorary" #name))
  836.    ))
  837.  
  838.    (debug "target dignorary = " #target-dignorary)
  839. ))
  840.  
  841. ;----------------------------------------------------------------------------
  842. ; Move temporary dignorary to standard dignorary directory
  843. ;----------------------------------------------------------------------------
  844. (procedure P-move-dignorary #source-dignorary
  845. (
  846.    (debug "move dignorary")
  847.    (debug "  source = \"" #source-dignorary "\"")
  848.    (debug "  target = \"" #target-dignorary "\"")
  849.  
  850.    (copyfiles
  851.       (source #source-dignorary)
  852.       (dest (pathonly #target-dignorary))
  853.       (newname (fileonly #target-dignorary))
  854.       (optional "askuser")
  855.    )
  856.  
  857.    (delete #source-dignorary (optional "force"))
  858. ))
  859.  
  860.  
  861. ;----------------------------------------------------------------------------
  862. ; Ask for JavaDoc directory
  863. ;----------------------------------------------------------------------------
  864.  
  865. (procedure P-ask-javadoc-directory
  866. (
  867.    (debug "ask javadoc directory")
  868.  
  869.    (set #javadoc-exists 0)
  870.  
  871.    (set #javadoc-directory
  872.    (askdir
  873.       (prompt #prompt-javadoc-directory)
  874.       (help #help-javadoc-directory)
  875.       (default "jdk:jdk1.2.2/docs/api/index-files")
  876.    ))
  877.  
  878.    ; Check, if "a-index.html" exists in this directory
  879.    (set #javadoc-exist (exists (tackon #javadoc-directory "index-1.html")))
  880.  
  881.    (debug "#javadoc-exist = " #javadoc-exist)
  882.  
  883.    ; If not, annoy user
  884.    (if (= 0 #javadoc-exist) (abort #message-bad-javadoc-directory))
  885. ))
  886.  
  887. ;----------------------------------------------------------------------------
  888. ; Scan JavaDoc index file and append references to dignorary
  889. ;----------------------------------------------------------------------------
  890. (procedure P-scan-javadoc #filename #complete2
  891. (
  892.    ; Compute name of index file to scan
  893.    (set #javadoc-filename (tackon #javadoc-directory #filename))
  894.  
  895.    (debug "scan " #javadoc-filename)
  896.  
  897.    (complete #complete2)
  898.    (working (#working-scan-javadoc #javadoc-filename))
  899.  
  900.    ; Compute command to scan
  901.    (set #command-scan-javadoc
  902.    (cat "tschak/scan_javadoc <\"" #javadoc-filename "\" >>\"t:java.ignore\""
  903.    ))
  904.  
  905.    (P-run "#command-scan-javadoc" 0 #command-scan-javadoc)
  906. ))
  907.  
  908.  
  909. ;----------------------------------------------------------------------------
  910. ; Scan JavaDoc directory and create dignorary from it
  911. ;----------------------------------------------------------------------------
  912. (procedure P-scan-javadoc-directory #complete
  913. (
  914.    (debug "scan javadoc directory")
  915.  
  916.    (set #script-cleanup-dignorary "t:cleanup-dignorary")
  917.  
  918.    ; Setup temporary files
  919.    (P-run "#command-reset-scan" 0 "echo \"\" >t:java.ignore noline")
  920.    (P-run "#command-reset-scan" 0 "echo \"\" >t:dummy.java")
  921.    (P-run "#command-reset-scan" 0 "echo \"dummy.java\" >t:java.files")
  922.    (delete "t:java.names")
  923.  
  924.    (set #scan-complete 0)
  925.    (foreach #javadoc-directory "index-#?.html"
  926.       (
  927.          (set #scan-complete (+ #scan-complete 1))
  928.          (P-scan-javadoc @each-name (+ #complete #scan-complete))
  929.       )
  930.    )
  931.  
  932.    (complete (+ #complete 30))
  933.    (working #working-cleanup-javadoc)
  934.  
  935.    (set #command-cleanup-dignorary
  936.    (cat "cd t:\n"
  937.         #expanded-vahunz " --base-name java --no-warning --quiet\n"
  938.    ))
  939.  
  940.    (textfile
  941.       (dest #script-cleanup-dignorary)
  942.       (append #command-cleanup-dignorary)
  943.    )
  944.  
  945.    (P-execute "#script-cleanup-dignorary" 0 #script-cleanup-dignorary)
  946.    (delete #script-cleanup-dignorary)
  947.  
  948.    (debug "cleanup temporary files")
  949.    (delete "t:java.(files|names)"  (optional "force"))
  950.    (delete "t:dummy.java" (optional "force"))
  951. ))
  952.  
  953. ;----------------------------------------------------------------------------
  954. ; Exit message for created dignoraries
  955. ;----------------------------------------------------------------------------
  956.  
  957. (procedure P-exit-dignorary
  958.    (debug "cleanup temporary files for dignoraries")
  959.    (delete "t:temporary.(files|ignore|names)"  (optional "force"))
  960.    (exit
  961.        (#message-exit-dignorary #target-dignorary)
  962.        (quiet)
  963. ))
  964.  
  965. ;----------------------------------------------------------------------------
  966. ; "Wollt ihr das totale Programm?"
  967. ;----------------------------------------------------------------------------
  968.  
  969. (complete   0) (P-check-requirements)
  970. (complete   5) (P-welcome)
  971.  
  972. (complete  10) (P-ask-vahunz-mode)
  973.  
  974. (set #flow-selector 0)
  975. (if (= #vahunz-options "*create-c*")    (set #flow-selector 1))
  976. (if (= #vahunz-options "*create-java*") (set #flow-selector 2))
  977.  
  978. (select #flow-selector
  979.    (
  980.       ; Vahunz source code
  981.       (complete  20) (P-ask-custom-switches)
  982.       (complete  25) ; (P-ask-custom-name-length)
  983.       (complete  30) ; (P-ask-custom-prefix)
  984.       (complete  35) ; (P-ask-custom-random-seed)
  985.       (complete  40) ; (P-ask-custom-vahunz-length)
  986.       (complete  45) (P-ask-source-type)
  987.       (complete  50) (P-ask-source-directory)
  988.       (complete  55) (P-ask-source-pattern)
  989.       (complete  60) (P-ask-dignorary)
  990.       (complete  65) (P-ask-target-directory)
  991.  
  992.       (complete  75) (P-create-vahunz.files)
  993.       (complete  80) (P-create-vahunz.ignore)
  994.       (complete  85) (P-create-vahunz-it)
  995.       (complete  90) (P-invoke-vahunz-it)
  996.       (complete  95) (P-edit-vahunz.names)
  997.       (complete 100) (P-exit)
  998.    )
  999.    (
  1000.       ; Create C/C++ dignorary
  1001.       (complete  30) (P-ask-include-directory)
  1002.       (complete  50) (P-ask-target-dignorary "amiga.ignore")
  1003.       (complete  70) (P-create-include-files)
  1004.       (complete  80) (P-scan-include-files)
  1005.       (complete  90) (P-translate-dignorary)
  1006.       (complete  95) (P-move-dignorary "t:temporary.ignore")
  1007.       (complete 100) (P-exit-dignorary)
  1008.    )
  1009.    (
  1010.       ; Create Java dignorary
  1011.       (complete  30) (P-ask-javadoc-directory)
  1012.       (complete  50) (P-ask-target-dignorary "java.ignore")
  1013.       (complete  60) (P-scan-javadoc-directory 60)
  1014.       (complete  95) (P-move-dignorary "t:java.ignore")
  1015.       (complete 100) (P-exit-dignorary)
  1016.    )
  1017. )
  1018.  
  1019.